from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from time import sleep
from selenium import webdriver

driver = webdriver.Edge()
driver.maximize_window()
driver.get('https://www.jiuxian.com/')
sleep(2)
# 点击请登录
dl = driver.find_element(By.CLASS_NAME,'headerLogin')
dl.click()
sleep(1)
# 输入账号
driver.find_element(By.ID,'userName').send_keys('18185603008')
sleep(2)
# 输入密码
driver.find_element(By.ID,'password').send_keys('123456Aa')
sleep(10)
# 点击登录
driver.find_element(By.NAME,'bi_Usuallogin').click()
sleep(2)
# 点击确定
driver.find_element(By.ID,'bindSub').click()
sleep(5)
# 点击我的订单
driver.find_element(By.XPATH, '/html/body/div[2]/div/div[2]/ul/li[1]/div[1]/a').click()
sleep(2)
# 窗口切换
driver.switch_to.window(driver.window_handles[-1])
sleep(1)
# 向下滑动
driver.execute_script("window.scrollTo(0,800)")
sleep(2)
# 点击收货地址
driver.find_element(By.XPATH, '/html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span').click()
sleep(2)
# 点击添加收货地址
driver.find_element(By.XPATH,'/html/body/div[4]/div[3]/div[1]/a').click()
sleep(2)
# 输入收货人
driver.find_element(By.ID,'people').send_keys('小刘')
sleep(2)
# select 选择器
# index 省
province = Select(driver.find_element(By.ID,'province'))
province.select_by_index(1)
sleep(2)
# value 市
city = Select(driver.find_element(By.ID,'city'))
city.select_by_value('52')
sleep(2)
# visible text区
district = Select(driver.find_element(By.ID,'district'))
district.select_by_visible_text('昌平区')
sleep(5)